/*
* $Id: ViewJournalFactory.cpp 162 2010-10-04 11:21:18Z volok-aleksej@yandex.ru $
*
* Copyright 2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "ViewJournalFactory.h"
#include "ViewJournal.h"
#include "ViewJournal/ViewPoints.h"
#include "ViewJournal/ViewFamilies.h"
#include "ViewJournal/ViewInspects.h"
#include "ViewJournal/AddChangePointView.h"
#include "ViewJournal/AddChangeFamilyView.h"
#include "ViewJournal/AddChangeInspectView.h"
#include "ViewQueenBee/QBeePointView.h"
#include "ViewQueenBee/QBeeFamilyView.h"
#include "ViewQueenBee/QBeeInspectView.h"
#include "ViewQueenBee/AddQueenBeeView.h"
#include "ViewQueenBee/ChangeQueenBeeView.h"

CViewJornalFactory::CViewJornalFactory(){}

void CViewJornalFactory::Init(CState* state){
	m_emptyView = new CEmptyViewJournal(state);
	m_aViewJournal.push_back(new CViewPoints(state));
	m_aViewJournal.push_back(new CViewFamilies(state));
	m_aViewJournal.push_back(new CViewInspect(state));
	m_aViewJournal.push_back(new CAddPointView(state));
	m_aViewJournal.push_back(new CChangePointView(state));
	m_aViewJournal.push_back(new CAddFamilyView(state));
	m_aViewJournal.push_back(new CChangeFamilyView(state));
	m_aViewJournal.push_back(new CAddInspectView(state));
	m_aViewJournal.push_back(new CChangeInspectView(state));
	m_aViewJournal.push_back(new CQBeePointView(state));
	m_aViewJournal.push_back(new CQBeeFamilyView(state));
	m_aViewJournal.push_back(new CQBeeInspectView(state));
	m_aViewJournal.push_back(new CAddQueenBeeView(state));
	m_aViewJournal.push_back(new CChangeQueenBeeView(state));
}

CViewJornalFactory::~CViewJornalFactory(){
	for(std::vector<IViewJournal*>::iterator it = m_aViewJournal.begin(); it != m_aViewJournal.end(); it++)
		(*it)->Free();
	m_emptyView->Free();
}

IViewJournal* CViewJornalFactory::GetViewJournal(State state){
	for(std::vector<IViewJournal*>::iterator it = m_aViewJournal.begin(); it != m_aViewJournal.end(); it++){
		if(((*it)->IsViewState(state))){
			(*it)->SetState();
			return *it;
		}
	}
	m_emptyView->SetState();
	return m_emptyView;
}